﻿using Newtonsoft.Json;
using ShopeeSdk.Response.Shopee.Item;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ShopeeSdk.Request.Shopee.Item
{

    public class ItemAddRequest : ShopeeRequest<ItemAddResponse>
    {
        [JsonProperty("category_id")]
        public int CategoryId { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }

        [JsonProperty("price")]
        public float Price { get; set; }

        [JsonProperty("stock")]
        public int Stock { get; set; }

        [JsonProperty("item_sku")]
        public string ItemSku { get; set; }

        [JsonProperty("variations")]
        public List<Variation> Variations { get; set; } = new List<Variation>();

        [JsonProperty("images")]
        public List<Image> Images { get; set; } = new List<Image>();

        [JsonProperty("attributes")]
        public List<Attribute> Attributes { get; set; } = new List<Attribute>();

        [JsonProperty("logistics")]
        public List<Logistic> Logistics { get; set; } = new List<Logistic>();

        [JsonProperty("weight")]
        public float Weight { get; set; }

        [JsonProperty("package_length")]
        public int ? PackageLength { get; set; }

        [JsonProperty("package_width")]
        public int ? PackageWidth { get; set; }

        [JsonProperty("package_height")]
        public int ? PackageHeight { get; set; }

        [JsonProperty("days_to_ship")]
        public int ? DaysToShip { get; set; }

        [JsonProperty("wholesales")]
        public List<Wholesale> Wholesales { get; set; } = new List<Wholesale>();

        [JsonProperty("size_chart")]
        public string SizeChart { get; set; } = string.Empty;

        /// <summary>
        /// 是否二手NEW/USED  默认 NEW
        /// </summary>
        [JsonProperty("condition")]
        public string Condition { get; set; } = "NEW";

        public override string RequestUrlEndPath => "item/add";

        public class Variation
        {

            [JsonProperty("name")]
            public string Name { get; set; }

            [JsonProperty("stock")]
            public int Stock { get; set; }

            [JsonProperty("price")]
            public float Price { get; set; }

            [JsonProperty("variation_sku")]
            public string VariationSku { get; set; }
        }

        public class Image
        {

            [JsonProperty("url")]
            public string Url { get; set; }
        }

        public class Attribute
        {
            [JsonProperty("attributes_id")]
            public int AttributesId { get; set; }

            [JsonProperty("value")]
            public string Value { get; set; }
        }

        public class Logistic
        {
            [JsonProperty("logistic_id")]
            public int LogisticId { get; set; }

            [JsonProperty("enabled")]
            public bool Enabled { get; set; }

            [JsonProperty("shipping_fee")]
            public float ShippingFee { get; set; }

            [JsonProperty("size_id")]
            public int SizeId { get; set; }

            [JsonProperty("is_free")]
            public bool IsFree { get; set; }
        }

        public class Wholesale
        {
            [JsonProperty("min")]
            public int Min { get; set; }

            [JsonProperty("max")]
            public int Max { get; set; }

            [JsonProperty("unit_price")]
            public float UnitPrice { get; set; }
        }
    }



}
